<?php
/*
 * This file is part of the oGUI package.
 * (c) 2010 Martin Vancura, DiS. <vancura@martinvancura.cz>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
*/

/**
 * OgPointers.
 * Singleton which hold pointers on gettable components
 *
 * @package    oGUI
 * @subpackage core
 * @author     Martin Vancura, DiS. <vancura@martinvancura.cz>
 */
class OgPointers {

  protected $pointers;
  protected static $singleton;

  /**
   * Returns instance of Pointer holder
   *
   * @author Martin Vancura, DiS. <vancura@martinvancura.cz>
   * @access public
   * @static
   * @return OgPointers
   */
  public static function singleton() {
    if (self::$singleton === null) {
      self::$singleton = new OgPointers();
    }
    return self::$singleton;
  }

  /**
   * Adds pointer to holder Array
   *
   * @author Martin Vancura, DiS. <vancura@martinvancura.cz>
   * @access public
   * @param String $key
   * @param OgElement $pointer
   */
  public function addPointer($key, $pointer) {
    $this->pointers[$key] = $pointer;
  }

  /**
   * Gets pointer by name
   *
   * @author Martin Vancura, DiS. <vancura@martinvancura.cz>
   * @access public
   * @param <type> $name
   * @return <type>
   */
  public function getPointer($name) {
    return $this->pointers[$name];
  }
}
?>
